using System;
using System.Data;
using System.Collections.Generic;

namespace SERP.DAO{
	/********************************BEGIN UsersDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:09/03/2013 19:09:04</para>
	/// <para>Class Name: UsersDAO</para>
	/// <para>Description: Class access to table Users in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class UsersDAO : DAOBase<UsersEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: UserId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int UserId){
			string strSQL="SELECT  [UserId],[UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType] FROM [Users]  WHERE [Users].[UserId]=@UserId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@UserId",UserId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: UserId</para>
		/// <para>Output: UsersEntity</para>
		///</summary>
		public UsersEntity SelectOne(int UserId){
			IDbCommand cmd=this.CreateSelectOneCommand(UserId);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [UserId],[UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType] FROM [Users] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [UserId],[UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType] FROM [Users]  WHERE [Users].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of UsersEntity</para>
		///</summary>
		public List<UsersEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [UserId],[UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType] FROM [Users]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [UserId],[UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType] FROM [Users]  WHERE [Users].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of UsersEntity</para>
		///</summary>
		public List<UsersEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(UsersEntity o){
			string strSQL="INSERT INTO [Users]([UserName],[Password],[DisplayName],[BirthDay],[Email],[Gender],[Address],[Phone],[IsActived],[UserType]) VALUES  (@UserName,@Password,@DisplayName,@BirthDay,@Email,@Gender,@Address,@Phone,@IsActived,@UserType);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullUserName)
				this.CreateCommandParameter(cmd,"@UserName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserName",o.UserName);

			if(o.IsNullPassword)
				this.CreateCommandParameter(cmd,"@Password",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Password",o.Password);

			if(o.IsNullDisplayName)
				this.CreateCommandParameter(cmd,"@DisplayName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DisplayName",o.DisplayName);

			if(o.IsNullBirthDay)
				this.CreateCommandParameter(cmd,"@BirthDay",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@BirthDay",o.BirthDay);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullGender)
				this.CreateCommandParameter(cmd,"@Gender",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Gender",o.Gender);

			if(o.IsNullAddress)
				this.CreateCommandParameter(cmd,"@Address",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Address",o.Address);

			if(o.IsNullPhone)
				this.CreateCommandParameter(cmd,"@Phone",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Phone",o.Phone);

			if(o.IsNullIsActived)
				this.CreateCommandParameter(cmd,"@IsActived",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsActived",o.IsActived);

			if(o.IsNullUserType)
				this.CreateCommandParameter(cmd,"@UserType",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserType",o.UserType);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Save</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(UsersEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.UserId=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of UsersEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<UsersEntity>list){
			foreach(UsersEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(UsersEntity o){
			string strSQL="UPDATE  [Users] SET [Users].[UserName]=@UserName,[Users].[Password]=@Password,[Users].[DisplayName]=@DisplayName,[Users].[BirthDay]=@BirthDay,[Users].[Email]=@Email,[Users].[Gender]=@Gender,[Users].[Address]=@Address,[Users].[Phone]=@Phone,[Users].[IsActived]=@IsActived,[Users].[UserType]=@UserType WHERE [Users].[UserId]=@UserId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullUserName)
				this.CreateCommandParameter(cmd,"@UserName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserName",o.UserName);

			if(o.IsNullPassword)
				this.CreateCommandParameter(cmd,"@Password",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Password",o.Password);

			if(o.IsNullDisplayName)
				this.CreateCommandParameter(cmd,"@DisplayName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DisplayName",o.DisplayName);

			if(o.IsNullBirthDay)
				this.CreateCommandParameter(cmd,"@BirthDay",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@BirthDay",o.BirthDay);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullGender)
				this.CreateCommandParameter(cmd,"@Gender",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Gender",o.Gender);

			if(o.IsNullAddress)
				this.CreateCommandParameter(cmd,"@Address",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Address",o.Address);

			if(o.IsNullPhone)
				this.CreateCommandParameter(cmd,"@Phone",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Phone",o.Phone);

			if(o.IsNullIsActived)
				this.CreateCommandParameter(cmd,"@IsActived",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsActived",o.IsActived);

			if(o.IsNullUserType)
				this.CreateCommandParameter(cmd,"@UserType",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserType",o.UserType);

			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,UserId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int UserId){
			string strSQL="UPDATE  [Users] SET [Users].["+ColumnName+"]=@ColumnName WHERE [Users].[UserId]=@UserId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@UserId",UserId);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Update</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(UsersEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of UsersEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<UsersEntity>list){
			foreach(UsersEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateUserName</para>
		/// <para>Input: NewUserName,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateUserName(string NewUserName,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("UserName",NewUserName,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePassword</para>
		/// <para>Input: NewPassword,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePassword(string NewPassword,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Password",NewPassword,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateDisplayName</para>
		/// <para>Input: NewDisplayName,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDisplayName(string NewDisplayName,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DisplayName",NewDisplayName,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateBirthDay</para>
		/// <para>Input: NewBirthDay,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateBirthDay(DateTime NewBirthDay,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("BirthDay",NewBirthDay,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateEmail</para>
		/// <para>Input: NewEmail,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateEmail(string NewEmail,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Email",NewEmail,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateGender</para>
		/// <para>Input: NewGender,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGender(Byte NewGender,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Gender",NewGender,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateAddress</para>
		/// <para>Input: NewAddress,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateAddress(string NewAddress,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Address",NewAddress,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePhone</para>
		/// <para>Input: NewPhone,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePhone(string NewPhone,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Phone",NewPhone,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateIsActived</para>
		/// <para>Input: NewIsActived,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateIsActived(bool NewIsActived,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("IsActived",NewIsActived,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateUserType</para>
		/// <para>Input: NewUserType,UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateUserType(Byte NewUserType,int UserId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("UserType",NewUserType,UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [Users]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(UsersEntity o){
			string strSQL="DELETE   FROM [Users]   WHERE [Users].[UserId]=@UserId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: UserId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int UserId){
			string strSQL="DELETE   FROM [Users]   WHERE [Users].[UserId]=@UserId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@UserId",UserId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [Users]   WHERE [Users].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Delete</para>
		/// <para>Input: UsersEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(UsersEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: UserId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int UserId){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(UserId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select,delete by UserId functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: UsersEntity</para>
		///</summary>
		protected override UsersEntity MapObject(IDataReader r){
			UsersEntity entity = new UsersEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("UserId");
						if (!r.IsDBNull(ordinal)) entity.UserId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("UserName");
						if (!r.IsDBNull(ordinal)) entity.UserName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Password");
						if (!r.IsDBNull(ordinal)) entity.Password = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DisplayName");
						if (!r.IsDBNull(ordinal)) entity.DisplayName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("BirthDay");
						if (!r.IsDBNull(ordinal)) entity.BirthDay = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Email");
						if (!r.IsDBNull(ordinal)) entity.Email = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Gender");
						if (!r.IsDBNull(ordinal)) entity.Gender = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Address");
						if (!r.IsDBNull(ordinal)) entity.Address = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Phone");
						if (!r.IsDBNull(ordinal)) entity.Phone = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("IsActived");
						if (!r.IsDBNull(ordinal)) entity.IsActived = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("UserType");
						if (!r.IsDBNull(ordinal)) entity.UserType = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END UsersDAOBase*****************************************/
	/*****************************************************************************************************/
}

